From 60d39e973a60baaae210be36135cc478dc2c0a96 Mon Sep 17 00:00:00 2001 From: "Jasper St. Pierre" Date: Fri, 20 Jun 2014 20:47:59 -0400 Subject: [PATCH] gdkwindow: Squash a leak in the subsurface case cairo_surface_create_for_rectangle takes a ref on the parent surface, so we need to drop ours. Rename get_window_surface to ref_window_surface to make the code more clear and to stop this error from happening again. --- gdk/gdkwindow.c | 17 ++++++++++------- 1 file changed, 10 insertions(+), 7 deletions(-) diff --git a/gdk/gdkwindow.c b/gdk/gdkwindow.c index 7638a33655..36d01e4cce 100644 --- a/gdk/gdkwindow.c +++ b/gdk/gdkwindow.c @@ -2984,7 +2984,7 @@ gdk_window_clear_backing_region (GdkWindow *window, * or the actual impl surface of the window. This should not be used * from very many places: be careful! */ static cairo_surface_t * -get_window_surface (GdkWindow *window) +ref_window_surface (GdkWindow *window) { if (window->impl_window->current_paint.surface) return cairo_surface_reference (window->impl_window->current_paint.surface); @@ -3002,7 +3002,7 @@ _gdk_window_ref_cairo_surface (GdkWindow *window) g_return_val_if_fail (GDK_IS_WINDOW (window), NULL); - surface = get_window_surface (window); + surface = ref_window_surface (window); if (gdk_window_has_impl (window)) { @@ -3010,11 +3010,14 @@ _gdk_window_ref_cairo_surface (GdkWindow *window) } else { - return cairo_surface_create_for_rectangle (surface, - window->abs_x, - window->abs_y, - window->width, - window->height); + cairo_surface_t *subsurface; + subsurface = cairo_surface_create_for_rectangle (surface, + window->abs_x, + window->abs_y, + window->width, + window->height); + cairo_surface_destroy (surface); + return subsurface; } } -- 2.30.2